package cn.credit.loan.service.authority;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.credit.loan.dao.authority.AuthorityMapper;
import cn.credit.loan.entity.Authority;

@Service
@Transactional
public class AuthorityServiceImpl implements AuthorityService {
	@Autowired
	public AuthorityMapper authorityMapper;
	
	/**
	 * 权限管理员登录
	 */
	@Override
	public Authority login(String authorityName, String authorityPwd) throws Exception {
		if(authorityName.trim()!=null && authorityPwd.trim()!=null)
		{
			Authority authoritys=authorityMapper.login(authorityName, authorityPwd);
			if(authoritys!=null){
				return authoritys;
			}
		}
		return null;
	}
	
	/**
	 * 权限管理员添加
	 */
	@Override
	public boolean authorityAdd(Authority authority) throws Exception {
		if(authority!=null)
		{
			int num=authorityMapper.authorityAdd(authority);
			if(num>0)
			{
				return true;
			}
		}
		return false;
	}
	
	/**
	 * 权限管理员更新
	 */
	@Override
	public boolean authorityUpdate(Authority authority) throws Exception {
		if(authority!=null)
		{
			int num=authorityMapper.authorityUpdate(authority);
			if(num>0)
			{
				return true;
			}
		}
		return false;
	}
	
	/**
	 * 权限管理员删除
	 */
	@Override
	public boolean authorityDelete(int authorityId) throws Exception {
		return authorityMapper.authorityDelete(authorityId);
	}
}
